//
//  ECUIVC_CourseList.m
//  Edu_iOS2018
//
//  Created by yanyan on 2018/1/6.
//  Copyright © 2018年 yanyan. All rights reserved.
//

#import "ECUIVC_CourseList.h"
#import "ECUIVC_CourseDetail.h"
#import "searchPageViewController.h"
#import "ECUIView_CourseList.h"
#import "UINavigationBar+Awesome.h"
@interface ECUIVC_CourseList ()
@property(nonatomic,strong)ECUIView_CourseList *listView;
@end

@implementation ECUIVC_CourseList

-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        self.hidesBottomBarWhenPushed = YES;
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
}
- (void)addBarButtons
{
    [super addBarButtons];
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@""style:UIBarButtonItemStylePlain target:self action:nil];

    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"nav_list_search"] style:UIBarButtonItemStylePlain target:self action:@selector(action_rightBar:)];
    [self.navigationController.navigationBar lt_setBackgroundColor:[UIColor whiteColor]];
    //排序 popular：人气，priceDesc：价格 降序，priceAsc：价格升序
}
- (void)action_rightBar:(id)sender{
    searchPageViewController *vc_search = [[searchPageViewController alloc]init];
    vc_search.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc_search animated:YES];
}
- (void)addSubviews
{
    [super addSubviews];
    WeakSelf(weakSelf);
    _listView = [[ECUIView_CourseList alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - kNavHeight)];
    [self.view addSubview:_listView];
    if (!_listView.categorysData && self.categorysData) {
        _listView.categorysData = self.categorysData;

    }
    if (self.selectCategory) {
        [_listView setSelectCategory:self.selectCategory];

    }
    _listView.keyName = nil;

}
- (void)setSelectCategory:(PrimaryCategoryModel *)selectCategory
{
    _selectCategory = selectCategory;
    [_listView setSelectCategory:selectCategory];

}
- (void)showCourseDetail:(id)obj
{
    ECUIVC_CourseDetail* uivc_detail = [[ECUIVC_CourseDetail alloc]init];
    uivc_detail.hidesBottomBarWhenPushed = YES;
    uivc_detail.object = obj;
    [self.navigationController pushViewController:uivc_detail animated:YES];
    
}


/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
